import axios from 'axios'

axios.defaults.baseURL = "/api" //设置axios请求的模板路由
axios.defaults.headers.token = "1asd132fas23df1sa21df321sad3f2123sdfa11" //设置请求头内容

const request_interceptors = axios.interceptors.request.use(
    function(request){
        request.headers["hhh"] = "xxx" //每次请求都执行
        return request
    }//拦截器功能函数，自动接受请求，必须返回请求
) //请求拦截器

axios.interceptors.request.eject(request_interceptors) //删除拦截器


// const response_interceptors = axios.interceptors.response.use(
//     function(response){
//         console.log(response.data)
//         return response.data
//     }
// )
axios.interceptors.response.use(
    function(response){
        return response.data
    }
)
// axios.interceptors.response.eject(response_interceptors) //删除拦截器
export default axios